package com.example.project.key.Dao.mission;

import com.example.project.key.IBaseDao.IBasemission;
import com.example.project.key.object.mission;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class missionDao implements IBasemission {
    private static PreparedStatement stmt = null;
    mission m1 = new mission();
    @Override
    public boolean add(Connection con, String mission, String company, String mt) {
        return false;
    }

    @Override
    public boolean delete(Connection con, String company, String mt) {
        return false;
    }

    @Override
    public boolean modify(Connection con, String company, String mt) {
        return false;
    }

    @Override
    public mission find(Connection con, String company, String mt) {
        if(con!=null)
        {
            String sql="select * from mission where company = ? and mt = ?";
            try {
                stmt=con.prepareStatement(sql);
                stmt.setString(1,company);
                stmt.setString(2,mt);
                ResultSet rs= stmt.executeQuery();
                while (rs.next())
                {
                    m1.setMission(rs.getString("mission"));
                    m1.setMission_time(rs.getString("mt"));
                    m1.setCompany(rs.getString("company"));
                    m1.setMission_num(rs.getInt("mission_num"));
                }

            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            return m1;
        }else {
            return null;
        }
    }
}
